package ru.ncedu.java.vlku.hrs.uil.cmd;

import ru.ncedu.java.vlku.hrs.bll.HRSManager;
import ru.ncedu.java.vlku.hrs.bll.HRSManagerFactory;
import ru.ncedu.java.vlku.hrs.model.Cargo;

public class UpdateCargo implements Command {
    // update cargo <id> <new_name> <new_weight>
    @Override
    public void execute(String[] args) {
        if (args.length != 5)
            throw new IllegalArgumentException();
        Long id = Long.parseLong(args[2]);
        Double weight = Double.parseDouble(args[4]);
        Cargo cargo = new Cargo(args[3], weight);
        cargo.setId(id);
        HRSManager manager = HRSManagerFactory.getInstance().getHRSManager();
        manager.updateCargo(cargo);
    }
}
